package java_test.io_test;

import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

public class FileRead {
    public static void main(String[] args) throws IOException {
        File file = new File("E:\\myTestJava\\javacode\\src\\main\\java\\java_test\\io_test\\java\\Hello.txt");
        file.createNewFile();
        FileWriter writer = new FileWriter(file);
        writer.write("This\n is\n an\n example\n读取数组中的内容");
        writer.flush();
        writer.close();
        FileReader fr = new FileReader(file);
        char[] a = new char[50];
        fr.read(a); // 读取数组中的内容
        for (char c : a)
            System.out.print(c); // 一个一个打印字符
        fr.close();

    }
}
